{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n",
      "Received request: b'Hello'\n"
     ]
    }
   ],
   "source": [
    "import zmq\n",
    "\n",
    "context = zmq.Context()\n",
    "socket = context.socket(zmq.REP)\n",
    "socket.connect(\"tcp://localhost:5560\")\n",
    "\n",
    "while True:\n",
    "    message = socket.recv()\n",
    "    print(\"Received request: %s\" % message)\n",
    "    socket.send(b\"World\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from kafka import KafkaProducer\n",
    "from kafka import KafkaConsumer\n",
    "import sys,time\n",
    "from kafka.client import KafkaClient\n",
    "\n",
    "#sys.path.irnsert(0,r'D:\\foo')||\n",
    "#print(sys.path)|\n",
    "#import face_v2\n",
    "#%pdb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "KafkaClient\t KafkaConsumer\t KafkaProducer\t TOPIC\t consumer\t ip\t kConsumer\t kProduct\t mes\t \n",
      "mes_js\t rmes\t sys\t threading\t time\t \n"
     ]
    }
   ],
   "source": [
    "# c=KafkaClient(bootstrap_servers='192.168.1.201:9092')\n",
    "# print(c.add_topic(\"BizPlatform_DataSync_UpChannel\"))\n",
    "TOPIC='test';ip='192.168.1.201:9092'\n",
    "%who\n",
    "    #BizPlatform_DataSync_UpChannel  BizPlatform_Filter_DataSync"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import threading\n",
    "mes=r'{\"action\":\"PersonRecordUpload\",\"data\":{\"personImages\":{\"720f6bc4-1a6d-4c2e-b9b5-27bef2f0aa6d\":\"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wAARCADRALQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRob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aQqt0BPf3qMzMaWU8VDUPQpDzIx700sfWm0VFxi5pM0UlAC0lFFIAopKKBi5pKKKACiiigAopKKACiiigAooooAKKKKACiiigAooooAKKKKALmkwvPqMKx43AlhnpkDI/UCu2WLGf3Knr1Ptx/hWF4Jtw97cTkZEcYUfUn/wCtXZbR6Cr2RD3KdqNxUlQuAeB2yatGlpDSEJSUtJQMKQ0tNNIDHqjrDFdPfb3IFXaqaqu/TpfbB/WtluSc5EMDJpC+ZV/GmSOVAApisdwJNQ30LsWJASBiq9PaT0JqOlJghaSiioKCikooAKKKKACiikoAWkoooAKKKKACiiigAooooAKKKKACikooAWkoooAKKKKAClpKWgDuPBkHl6U8pHMsh/Icf410BqlosH2bSLWLoRGCfqeT/OrhrR7mYhpppTSGkAlFFJQAUhpaQ0hmLSOokRkYZDDBpM80oNaknI30TwXDRuCMdPcetV812NzaQ3ceyZc+h7isW40GVMmCQOPQ8GplG+qKTMgGlzSzQSQPtlUq3oRSDpWbTW5QUUUlIYtJRRQAUUUUAFFFFABRRRQAUUUlAC0UlFABRRRQAUUUUAFFFFABRRRQAUUUUAFTWcJubyGAf8tHC/mahrY8KwedrkRIyIgXP5YH6kVUdxPY9AGAAB0pCaM1Wv55LeylmiTe6LkL61TMyc0VxzeKrs9FiH/AP/r1C/ia/bpIF+iCkVY7U0ma4Vte1Buty4+mBUR1e9Y83Ex/4GaQ7Hf0hrn9B1E3N3IhDpuUkKxJA6dM/Wt+mI//2Q==\"},\"personList\":[{\"abnorma_of_personnel_code\":\"\",\"alarm\":0,\"community_area_code\":\"\",\"community_area_name\":\"\",\"community_code\":\"75b4b9d7-5ec4-44b7-8a72-086f392ce4ef\",\"community_name\":\"123\",\"community_subareas_code\":\"\",\"community_subareas_name\":\"\",\"create_time\":\"2018-09-28 10:56:06\",\"disposal_grade\":0,\"idcard\":\"\",\"in_or_out\":1,\"latitude\":87.352,\"longitude\":43.521,\"opendoor\":0,\"opentype\":0,\"passageway_code\":\"{6f1c3454-dce1-4902-9722-971bce6cb151}\",\"passageway_name\":\"赛博特大门车辆出口\",\"personnel_label_code\":\"\",\"personnel_label_name\":\"\",\"personnel_name\":\"\",\"personnel_status\":0,\"personnel_type\":0,\"police_api_return_type\":\"-1\",\"remark\":\"\",\"score\":0,\"uuid\":\"720f6bc4-1a6d-4c2e-b9b5-27bef2f0aa6d\"}],\"vehicleImages\":{},\"vehicleList\":null},\"id\":\"65010432000\",\"type\":\"DataService\"}'\n",
    "mes_js=rmes=r'{\"action\":\"PersonRecordUpload\",\"data\":{\"personImages\":{\"720f6bc4-1a6d-4c2e-b9b5-27bef2f0aa6d\":\"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wAARCADRALQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqO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npkDI/UCu2WLGf3Knr1Ptx/hWF4Jtw97cTkZEcYUfUn/wCtXZbR6Cr2RD3KdqNxUlQuAeB2yatGlpDSEJSUtJQMKQ0tNNIDHqjrDFdPfb3IFXaqaqu/TpfbB/WtluSc5EMDJpC+ZV/GmSOVAApisdwJNQ30LsWJASBiq9PaT0JqOlJghaSiioKCikooAKKKKACiikoAWkoooAKKKKACiiigAooooAKKKKACikooAWkoooAKKKKAClpKWgDuPBkHl6U8pHMsh/Icf410BqlosH2bSLWLoRGCfqeT/OrhrR7mYhpppTSGkAlFFJQAUhpaQ0hmLSOokRkYZDDBpM80oNaknI30TwXDRuCMdPcetV812NzaQ3ceyZc+h7isW40GVMmCQOPQ8GplG+qKTMgGlzSzQSQPtlUq3oRSDpWbTW5QUUUlIYtJRRQAUUUUAFFFFABRRRQAUUUlAC0UlFABRRRQAUUUUAFFFFABRRRQAUUUUAFTWcJubyGAf8tHC/mahrY8KwedrkRIyIgXP5YH6kVUdxPY9AGAAB0pCaM1Wv55LeylmiTe6LkL61TMyc0VxzeKrs9FiH/AP/r1C/ia/bpIF+iCkVY7U0ma4Vte1Buty4+mBUR1e9Y83Ex/4GaQ7Hf0hrn9B1E3N3IhDpuUkKxJA6dM/Wt+mI//2Q==\"},\"personList\":[{\"abnorma_of_personnel_code\":\"\",\"alarm\":0,\"community_area_code\":\"\",\"community_area_name\":\"\",\"community_code\":\"75b4b9d7-5ec4-44b7-8a72-086f392ce4ef\",\"community_name\":\"123\",\"community_subareas_code\":\"\",\"community_subareas_name\":\"\",\"create_time\":\"2018-09-28 10:56:06\",\"disposal_grade\":0,\"idcard\":\"ff998e95d240f57719\",\"in_or_out\":1,\"latitude\":87.352,\"longitude\":43.521,\"opendoor\":0,\"opentype\":0,\"passageway_code\":\"{6f1c3454-dce1-4902-9722-971bce6cb151}\",\"passageway_name\":\"赛博特大门车辆出口\",\"personnel_label_code\":\"\",\"personnel_label_name\":\"\",\"personnel_name\":\"\",\"personnel_status\":0,\"personnel_type\":0,\"police_api_return_type\":\"-1\",\"remark\":\"\",\"score\":0,\"uuid\":\"720f6bc4-1a6d-4c2e-b9b5-27bef2f0aa6d\"}],\"vehicleImages\":{},\"vehicleList\":null},\"id\":\"65010432000\",\"type\":\"DataService\"}'\n",
    "def kProduct(mes,peroid=1):\n",
    "    producer = KafkaProducer(bootstrap_servers=ip)\n",
    "    for i in range(5):\n",
    "        print(\"send\",i)\n",
    "        producer.send(TOPIC,bytes( mes,\"UTF-8\"))\n",
    "        time.sleep(peroid)\n",
    "    print(\"ok\")\n",
    "    producer.close()\n",
    "\n",
    "def kConsumer(topic):\n",
    "    try:\n",
    "        consumer = KafkaConsumer(topic, group_id='dataSyncGroup02',bootstrap_servers=ip)\n",
    "        print(\"start\")\n",
    "        for msg in consumer:\n",
    "            display=msg\n",
    "            #del display[\"feature\"]\n",
    "            print (display[:5],time.time())\n",
    "        print(\"stop\")\n",
    "    except:\n",
    "        consumer.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "startsend 0\n",
      "\n",
      "('test', 0, 23, 1545121934700, 0) 1545121934.8035018\n",
      "send 1\n",
      "('test', 0, 24, 1545121935701, 0) 1545121935.7164335\n",
      "send 2\n",
      "('test', 0, 25, 1545121936703, 0) 1545121936.733391\n",
      "send 3\n",
      "('test', 0, 26, 1545121937717, 0) 1545121937.7413862\n",
      "send 4\n",
      "('test', 0, 27, 1545121938724, 0) 1545121938.7553785\n",
      "ok\n"
     ]
    }
   ],
   "source": [
    "##### TOPIC =\"BizPlatform_Filter_DataSync\"\n",
    "threading.Thread(target=kProduct,args=(mes,) ).start()\n",
    "#time.sleep(1)\n",
    "\n",
    "\n",
    "#BizPlatform_Filter_DataSync\n",
    "kConsumer(TOPIC)\n",
    "\n",
    "\n",
    "#threading.Thread(target=kConsumer ).start()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "kConsumer(TOPIC)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send 0\n",
      "ok\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-13-6a8f0e8dd408>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mthreading\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mThread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtarget\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkProduct\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmes_js\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstart\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mconsumer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mKafkaConsumer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"BizPlatform_DataSync_UpChannel\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgroup_id\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'my_favorite_group'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mbootstrap_servers\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'192.168.1.201:9092 '\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mmsg\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mconsumer\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"消费 :{}\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;31m# consume output\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\site-packages\\kafka\\consumer\\group.py\u001b[0m in \u001b[0;36m__next__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m   1116\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_set_consumer_timeout\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1117\u001b[0m         \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1118\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mnext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_iterator\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1119\u001b[0m         \u001b[1;32mexcept\u001b[0m \u001b[0mStopIteration\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1120\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_iterator\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\site-packages\\kafka\\consumer\\group.py\u001b[0m in \u001b[0;36m_message_generator\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m   1050\u001b[0m         \u001b[1;32mwhile\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_consumer_timeout\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1051\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1052\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_coordinator\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpoll\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1053\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1054\u001b[0m             \u001b[1;31m# Fetch offsets for any subscribed partitions that we arent tracking yet\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\site-packages\\kafka\\coordinator\\consumer.py\u001b[0m in \u001b[0;36mpoll\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    279\u001b[0m                     \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_client\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpoll\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfuture\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmetadata_update\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    280\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 281\u001b[1;33m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mensure_active_group\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    282\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    283\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpoll_heartbeat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\site-packages\\kafka\\coordinator\\base.py\u001b[0m in \u001b[0;36mensure_active_group\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    401\u001b[0m                     \u001b[0mfuture\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin_future\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    402\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 403\u001b[1;33m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_client\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpoll\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfuture\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mfuture\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    404\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    405\u001b[0m                 \u001b[1;32mif\u001b[0m \u001b[0mfuture\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfailed\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\site-packages\\kafka\\client_async.py\u001b[0m in \u001b[0;36mpoll\u001b[1;34m(self, timeout_ms, future)\u001b[0m\n\u001b[0;32m    554\u001b[0m                     \u001b[0mtimeout\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmax\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[1;33m/\u001b[0m \u001b[1;36m1000\u001b[0m\u001b[1;33m)\u001b[0m  \u001b[1;31m# avoid negative timeouts\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    555\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 556\u001b[1;33m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_poll\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    557\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    558\u001b[0m             \u001b[1;31m# called without the lock to avoid deadlock potential\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\site-packages\\kafka\\client_async.py\u001b[0m in \u001b[0;36m_poll\u001b[1;34m(self, timeout)\u001b[0m\n\u001b[0;32m    572\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    573\u001b[0m         \u001b[0mstart_select\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 574\u001b[1;33m         \u001b[0mready\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_selector\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mselect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    575\u001b[0m         \u001b[0mend_select\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    576\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_sensors\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\selectors.py\u001b[0m in \u001b[0;36mselect\u001b[1;34m(self, timeout)\u001b[0m\n\u001b[0;32m    321\u001b[0m         \u001b[0mready\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    322\u001b[0m         \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 323\u001b[1;33m             \u001b[0mr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mw\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_select\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_readers\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_writers\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    324\u001b[0m         \u001b[1;32mexcept\u001b[0m \u001b[0mInterruptedError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    325\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mready\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\program files\\python36\\lib\\selectors.py\u001b[0m in \u001b[0;36m_select\u001b[1;34m(self, r, w, _, timeout)\u001b[0m\n\u001b[0;32m    312\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mplatform\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'win32'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    313\u001b[0m         \u001b[1;32mdef\u001b[0m \u001b[0m_select\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mw\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 314\u001b[1;33m             \u001b[0mr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mw\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mselect\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mselect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mw\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mw\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    315\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mw\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    316\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "\n",
    "threading.Thread(target=kProduct,args=(mes_js,) ).start()\n",
    "consumer = KafkaConsumer(\"BizPlatform_DataSync_UpChannel\", group_id='my_favorite_group',bootstrap_servers='192.168.1.201:9092 ')\n",
    "for msg in consumer:\n",
    "    print(\"消费 :{}\".format(msg.value.decode()))\n",
    "# consume output"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    " \n",
    "#threading.Thread(target=kConsumer ).start()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "kConsumer(\"BizPlatform_DataProcessor_UpChannel\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "code_folding": [
     3
    ]
   },
   "outputs": [],
   "source": [
    "for i in [1]:\n",
    "    if True:\n",
    "        break\n",
    "else:\n",
    "    print(111)\n",
    "\n",
    "d= {0:0,3:2, 23:{2:2}}\n",
    "del d[23][2]\n",
    "print(d)\n",
    "import math\n",
    "max(d.keys())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# produce 装饰器"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<kafka.producer.kafka.KafkaProducer object at 0x000002B40CEFC518> test\n"
     ]
    }
   ],
   "source": [
    "from kafka import KafkaProducer\n",
    "from kafka import KafkaConsumer\n",
    "import sys,time\n",
    "from kafka.client import KafkaClient\n",
    "\n",
    "\n",
    "# 装饰函数 发送到卡夫卡\n",
    "def sendReturn2Kafka(producer,topic,key=None,partition=None):\n",
    "    print(producer,topic)\n",
    "    def func(functionName):\n",
    "        def func_in(*args, **kwargs):\n",
    "            print(\"-----记录日志-----\")\n",
    "            ret = functionName(*args, **kwargs)\n",
    "            \n",
    "            producer.send(topic,ret,key=key)\n",
    "            return ret\n",
    "        return func_in\n",
    "    return func\n",
    "\n",
    "producerInfoMap={\"producer\": KafkaProducer(bootstrap_servers=ip),\"topic\":TOPIC,\"key\":b'123'}\n",
    "\n",
    "# 数据转换函数\n",
    "def num2str(functionName):\n",
    "    def func_in(*args):\n",
    "        ret = functionName(*args)\n",
    "        assert type(ret) is int  or type(ret) is float,\"return mast a number\"\n",
    "        return str(ret)\n",
    "    return func_in\n",
    "def num2bytes(functionName):\n",
    "    def func_in(*args):\n",
    "        print(\"-----记录日志-----\")\n",
    "        ret = functionName(*args)\n",
    "        assert type(ret) is int  or type(ret) is float,\"return mast a number\"\n",
    "        return bytes([ret])\n",
    "    return func_in\n",
    "# 任意一原函数\n",
    "\n",
    "@sendReturn2Kafka(**producerInfoMap)\n",
    "@num2bytes\n",
    "def  add(a,b):\n",
    "    return a+b\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "add(1,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 异步消费者\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import asyncio\n",
    "\n",
    "consumer = KafkaConsumer(\"test\", group_id='my_favorite_group',bootstrap_servers='192.168.1.201:9092 ')\n",
    "async def aKconsumer(consumer):\n",
    "    return next(consumer)\n",
    "async def show():\n",
    "    print ( await aKconsumer(consumer) )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Task pending coro=<show() running at <ipython-input-9-d8e2b3d0dab7>:6>>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# jupyter 中有额外的阻塞发生 ， 在执行异步消费后被阻塞了\n",
    "loop = asyncio.get_event_loop()\n",
    "loop.create_task(show())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## aiokafka"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Task pending coro=<consume() running at <ipython-input-1-fba75f15ec71>:6>>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'aiokafka.structs.ConsumerRecord'>\n",
      "consumed:  test 0 31 b'' b'11111111' 1550456823587\n",
      "<class 'aiokafka.structs.ConsumerRecord'>\n",
      "consumed:  test 0 32 None b'' -1\n",
      "<class 'aiokafka.structs.ConsumerRecord'>\n",
      "consumed:  test 0 33 None b'123456' -1\n"
     ]
    }
   ],
   "source": [
    "from aiokafka import AIOKafkaConsumer\n",
    "import asyncio\n",
    "\n",
    "loop = asyncio.get_event_loop()\n",
    "\n",
    "async def consume():\n",
    "    consumer = AIOKafkaConsumer(\n",
    "        'test', 'hello-world',\n",
    "        loop=loop, bootstrap_servers='192.168.1.201:9092',\n",
    "        group_id=\"my-group\")\n",
    "    # Get cluster layout and join group `my-group`\n",
    "    await consumer.start()\n",
    "    try:\n",
    "        # Consume messages\n",
    "        async for msg in consumer:\n",
    "            print(type(msg))\n",
    "            print(\"consumed: \", msg.topic, msg.partition, msg.offset,\n",
    "                  msg.key, msg.value, msg.timestamp)\n",
    "    finally:\n",
    "        # Will leave consumer group; perform autocommit if enabled.\n",
    "        await consumer.stop()\n",
    "\n",
    "loop.create_task(consume())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Task pending coro=<send_one() running at <ipython-input-4-da7e9e2e6540>:5>>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'aiokafka.structs.ConsumerRecord'>\n",
      "consumed:  test 0 35 None b'Super message' 1550481248446\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Failed fetch messages from 1: [Error 7] RequestTimedOutError\n",
      "Error sending HeartbeatRequest_v0 to node 1 [[Error 7] RequestTimedOutError] -- marking coordinator dead\n",
      "Marking the coordinator dead (node 1)for group my-group.\n",
      "Heartbeat send request failed: [Error 7] RequestTimedOutError. Will retry.\n",
      "Heartbeat session expired - marking coordinator dead\n",
      "Error sending OffsetCommitRequest_v2 to node 1 [ConnectionError: Connection at 192.168.1.201:9092 closed] -- marking coordinator dead\n",
      "Auto offset commit failed: ConnectionError: Connection at 192.168.1.201:9092 closed\n",
      "Unable connect to node with id 1: [Errno 10053] Connect call failed ('192.168.1.201', 9092)\n",
      "Unable to update metadata from [1]\n",
      "Unable connect to node with id 1: [Errno 10060] Connect call failed ('192.168.1.201', 9092)\n",
      "Group Coordinator Request failed: NodeNotReadyError: Attempt to send a request to node which is not ready (node id 1).\n",
      "OffsetCommit failed for group my-group due to group error ([Error 25] UnknownMemberIdError: my-group), will rejoin\n",
      "OffsetCommit failed for group my-group due to group error ([Error 25] UnknownMemberIdError: my-group), will rejoin\n",
      "OffsetCommit failed for group my-group due to group error ([Error 25] UnknownMemberIdError: my-group), will rejoin\n",
      "OffsetCommit failed for group my-group due to group error ([Error 25] UnknownMemberIdError: my-group), will rejoin\n",
      "Auto offset commit failed: [Error 25] UnknownMemberIdError: my-group\n",
      "Heartbeat failed: local member_id was not recognized; resetting and re-joining group\n",
      "Heartbeat session expired - marking coordinator dead\n",
      "Marking the coordinator dead (node 1)for group my-group.\n"
     ]
    }
   ],
   "source": [
    "from aiokafka import AIOKafkaProducer\n",
    "import asyncio\n",
    "\n",
    "loop2=asyncio.get_event_loop()\n",
    "async def send_one(data):\n",
    "    producer = AIOKafkaProducer(\n",
    "        loop=loop, bootstrap_servers='192.168.1.201:9092')\n",
    "    # Get cluster layout and initial topic/partition leadership information\n",
    "    await producer.start()\n",
    "    try:\n",
    "        # Produce message\n",
    "        await producer.send_and_wait(\"test\", data)\n",
    "    finally:\n",
    "        # Wait for all pending messages to be delivered or expire.\n",
    "        await producer.stop()\n",
    "loop2.create_task(send_one(b\"Super message\"))       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#命令\n",
    "# 一个源的操作作为原子命令\n",
    "cmd1={\n",
    "    \"cmd_serial\":1001,\n",
    "    \"broke\":\"192.168.1.201:9092\",\n",
    "    \"location\":\"qd01\",\n",
    "    \"key\":0\n",
    "    \"cmd\":{\"src\":\"/dev/video0\",\"func\":\"A\",\"sink\":\"local\"},\n",
    "}\n",
    "cmd2={\n",
    "    \"cmd_serial\":1002,\n",
    "    \"location\":\"qd01\",\n",
    "    \"key\":1\n",
    "    \"cmd\":{\"src\":\"/dev/video1\",\"func\":\"A\",\"sink\":\"local\"},\n",
    "}\n",
    "rep={\n",
    "    \"rnt\":\"success\",\n",
    "    \"err_message\":\"cant found src %xxx\"\n",
    "    \"video_cap_info\":{\"Width/Height\":\"800/488\",\n",
    "                      \n",
    "                     },\n",
    "    \n",
    "    \"host_info\":{\"ip\":\"192.168.1.112\"}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 流  Faust\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception in default exception handler\n",
      "Traceback (most recent call last):\n",
      "  File \"c:\\program files\\python36\\lib\\asyncio\\base_events.py\", line 1285, in call_exception_handler\n",
      "    New keys maybe introduced in the future.\n",
      "  File \"c:\\program files\\python36\\lib\\asyncio\\base_events.py\", line 1257, in default_exception_handler\n",
      "    tb = ''.join(traceback.format_list(value))\n",
      "  File \"c:\\program files\\python36\\lib\\asyncio\\base_tasks.py\", line 15, in _task_repr_info\n",
      "    coro = coroutines._format_coroutine(task._coro)\n",
      "  File \"c:\\program files\\python36\\lib\\asyncio\\coroutines.py\", line 274, in _format_coroutine\n",
      "AssertionError\n"
     ]
    }
   ],
   "source": [
    "import faust\n",
    "\n",
    "app = faust.App(\n",
    "    'hello-world',\n",
    "    broker='kafka://192.168.1.201:9092',\n",
    "    value_serializer='raw',\n",
    ")\n",
    "\n",
    "greetings_topic = app.topic('greetings')\n",
    "\n",
    "@app.agent(greetings_topic)\n",
    "async def greet(greetings):\n",
    "    async for greeting in greetings:\n",
    "        print(greeting)\n",
    "        \n",
    "if __name__ == '__main__':\n",
    "    loop = asyncio.get_event_loop()\n",
    "    loop.create_task(greet())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'NoneType' object is not iterable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-12-e0d2bb1421f8>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mkeyList\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34mb\"214\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34mb\"4223\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      3\u001b[0m     \u001b[0ma\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mkeyList\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m         \u001b[1;32massert\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m\u001b[0mbytes\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: 'NoneType' object is not iterable"
     ]
    }
   ],
   "source": [
    "keyList=[b\"214\",b\"4223\"]\n",
    "for i in None:\n",
    "    a\n",
    "for i in keyList:\n",
    "        assert type(i) ==bytes\n",
    "i=b\"214\"\n",
    "if i in keyList:  \n",
    "        print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6.78 µs ± 259 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit \n",
    "a=[]\n",
    "s=\"ddddddddddddddddddddashhhhhhhhhhhhhhhhhhhhhhhhhoussssssssssssssssssssssssouuusoooooooooooooooooooooooouuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\"\n",
    "for i in range(100):\n",
    "    a+=[s]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7.52 µs ± 507 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit \n",
    "a=[]\n",
    "s=\"ddddddddddddddddddddashhhhhhhhhhhhhhhhhhhhhhhhhoussssssssssssssssssssssssouuusoooooooooooooooooooooooouuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\"\n",
    "for i in range(100):\n",
    "    a.append(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "class MetaData:\n",
    "    def __init__(self):\n",
    "        self.image=bytes\n",
    "        self.alignedImage:bytes\n",
    "    def dimage(self):\n",
    "        return self.image\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b'1\\n2\\n3'\n"
     ]
    }
   ],
   "source": [
    "with open(\"city.txt\",\"rb\") as f:\n",
    "    print(f.read())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(1) is int"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
